Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[RLlib] Add a test for loading checkpoint v1.0 Policies using the new Policy.from_checkpoint(). #29370

Merged
merged 4 commits into from
Oct 25, 2022

Conversation

gjoliver
Copy link
Member

@gjoliver gjoliver commented Oct 14, 2022

Signed-off-by: Jun Gong [email protected]

Why are these changes needed?

Add a unit test to make sure problem fixed by 75e9722 doesn't happen again.

Related issue number

Checks

  • I've signed off every commit(by using the -s flag, i.e., git commit -s) in this PR.
  • I've run scripts/format.sh to lint the changes in this PR.
  • I've included any doc changes needed for https://docs.ray.io/en/master/.
  • I've made sure the tests are passing. Note that there might be a few flaky tests, see the recent failures at https://flakey-tests.ray.io/
  • Testing Strategy
    • [*] Unit tests
    • Release tests
    • This PR is not tested :(

)

policies = Policy.from_checkpoint(path_to_checkpoint)
self.assertTrue("default_policy", policies)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"default_policy" in policies

Also, nit nit: Can we use DEFAULT_POLICY_ID instead?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good catch. thanks.


print(algo.train())
algo.stop()

def test_v1_policy_from_checkpoint(self):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just for my understanding: Any reason, why we shouldn't just do this test case in a loop?

B/c you just want to test Policy (not algo)? Python/pickle versions?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you mean merge this test with the one above?
the thing is that I need to test DQN policies here. because that is the one we didn't finish migrating to PolicyV2.
it feels a special case compared to the other backward compatibility tests.
we can also remove this test once I move DQN, etc to PolicyV2.

Copy link
Contributor

@sven1977 sven1977 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice PR! Thanks for keeping us honest wrt backward compat :)
Just one question and one nit.

@sven1977 sven1977 changed the title Add a test for loading v1 policies using the new Policy.from_checkpoint() API. [RLlib] Add a test for loading checkpoint v1.0 Policies using the new Policy.from_checkpoint(). Oct 19, 2022
Jun Gong added 3 commits October 20, 2022 09:45
fix
Signed-off-by: Jun Gong <[email protected]>
fix
Signed-off-by: Jun Gong <[email protected]>
fix
Signed-off-by: Jun Gong <[email protected]>
Copy link
Contributor

@sven1977 sven1977 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for addressing the comments @gjoliver . Looks good now! :)
Please make sure all tests pass before merging.

@gjoliver gjoliver merged commit aa9a53a into ray-project:master Oct 25, 2022
WeichenXu123 pushed a commit to WeichenXu123/ray that referenced this pull request Dec 19, 2022
… `Policy.from_checkpoint()`. (ray-project#29370)

Signed-off-by: Jun Gong <[email protected]>
Signed-off-by: Weichen Xu <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants